﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Genealogy_Builder
{
    public partial class HasTraitDialog : Form
    {
        public Trait SelectedTrait;
        private bool wasCancelled;

        public HasTraitDialog(List<Trait> TraitList)
        {
            InitializeComponent();
            cmbTrait.DataSource = TraitList;
            wasCancelled = true;
        }
        public bool GetTrait()
        {
            wasCancelled = true;
            this.ShowDialog();
            return !wasCancelled;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            wasCancelled = true;
            this.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (cmbTrait.SelectedItem == null)
            {
                MessageBox.Show("Select a Value.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                wasCancelled = false;
                SelectedTrait = (Trait)cmbTrait.SelectedItem;
                this.Close();
            }
        }
    }
}
